package com.example.springbootpro.notic;

import com.example.springbootpro.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class ResponseAspect {

//    @Around("@annotation(com.example.springbootpro.annotation.ResponseWrapper) || " +
//            "@within(com.example.springbootpro.annotation.ResponseWrapper)")
    public Object wrapResponse(ProceedingJoinPoint joinPoint) throws Throwable {
        Object result = joinPoint.proceed();
        if (log.isDebugEnabled()) {
            log.debug("Method {} returned: {}", joinPoint.getSignature(), result);
        }
         return Result.success(result);
    }
}